import { type BrowserWindowConstructorOptions, app } from 'electron'
import createWindow from '../common/newWindow'
import services from './services'

/**
 * 创建系统设置窗口
 *
 * 有需要子窗口显示任务栏图标就不要绑定父级窗口
 *
 * @param parentWindow 父级窗口
 */
const openSystemSetting = async <T extends BrowserWindowConstructorOptions>() => {
  const mainWindow = await createWindow('#/system-setting', <T>{
    title: '系统设置',
    width: 500,
    height: 500
  })

  if (!mainWindow.isVisible()) {
    mainWindow.show()
  }

  mainWindow.setSkipTaskbar(false)

  mainWindow.setAppDetails({
    appId: 'setting'
  })

  services({ mainWindow, app })
  return { mainWindow, app }
}
export default openSystemSetting
